﻿
<#
.SYNOPSIS
    Collects TestResults to show to the current user (interactively).
.DESCRIPTION
    Displays TestResults. The user selected TestResults are returned to the pipeline.
#>
function Show-TestResult {
    [Cmdletbinding()]
    [OutputType([PsTest.Types.TestResult])]
    Param
    (
        <# The TestResults to display. #>
        [Parameter(Position=0, Mandatory=$true, ValueFromPipeline=$true, ValueFromPipelineByPropertyName=$true)]
        [PsTest.Types.TestResult[]]
        $TestResult,

        <# The title to use on the TestResults window. #>
        [string] $Title = "TestResults",

        <# The property to sort the TestResults on. #>
        [string] $Property = "State",

        <# Indicates that sorting must be done in descending order. #>
        [switch] $Descending = $true,

        <# Send selected items from the interactive window down the pipeline as input to other commands. #>
        [Microsoft.PowerShell.Commands.OutputModeOption] $OutputMode 
            = [Microsoft.PowerShell.Commands.OutputModeOption]::Multiple
    )

    Write-Trace "Sorting the TestResults"
    $sorted = $Input | Sort-Object -Property:$Property

    Write-Trace "Showing the TestResults"
    $sorted | Out-GridView -Title:$Title -OutputMode:$OutputMode
}
